var setting = {
	async: {
		enable: true,
		url:"/user/selectDepartTree",
		autoParam:["id", "name=departName"],
		otherParam:{"otherParam":"zTreeAsyncTest"},
		dataFilter: filter
	},
	data: {
		simpleData: {
			enable: true,
			idKey: "id",
			pIdKey: "parentId",
			rootPId: 0
		}
	},
	callback: {
		onClick:function (event, treeId, treeNode) {
//		    alert(treeNode.tId + ", " + treeNode.name);
			
			parent.$("#parentId").val(treeNode.id);
			parent.$("#prentdepart").val(treeNode.departName);
			
//			parent.$("")
			
			var selectlyser=parent.selectlyser;
			parent.layer.close(selectlyser);
			
//			console.log(mylay);
//		    console.log(event);
//		    console.log(treeId);
//		    console.log(treeNode);
		}
	}
};

function filter(treeId, parentNode, childNodes) {
	if (!childNodes) return null;
	for (var i=0, l=childNodes.length; i<l; i++) {
//		childNodes[i].name = childNodes[i].n.replace(/\.n/g, '.');
//		childNodes[i].name = childNodes[i].n;
		childNodes[i].name = childNodes[i].departName.replace(/\.n/g, '.');
	}
//	console.log(childNodes);
	return childNodes;
}

$(document).ready(function(){
	$.fn.zTree.init($("#treeDemo"), setting);
});